exports.organization_answer = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var skip = restfulParams.skip == undefined ? 0 : restfulParams.skip;

    var limit = restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;
    //任务流创建
    async.waterfall([
            //查询邀请问题
            function (cb) {

                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.questionOrganizationAnswer + "/fic_buid/" + restfulParams.organization_id + "/skip/" + skip + "/limit/" + limit,
                        method: 'POST',
                        data: {
                            fields: ["fc_id", "fic_id", "fc_title", "fc_images", "fc_collect_count", "fc_answer_count"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        resultData.inviteData = data.data;

                        cb();
                    }
                );
            },
            function (cb) {

                //创建添加任务
                var tasks = [];

                //循环节点列表
                resultData.inviteData.forEach(function (item, i) {

                    //创建每一个插入任务
                    tasks.push(function (cb) {

                        if (item.length !== 0) {
                            R.SEND_HTTP(
                                req,
                                {
                                    url: CORE_APIConfig.coreAPI.inviteLogUser + "/fil_ficid/" + item.fic_id,
                                    method: 'POST',
                                    data: {
                                        fields: ["u_nickname", "u_header_url"].join(",")
                                    }
                                },
                                function (err, data) {

                                    //console.log(data);

                                    item.inviteUser = data.data;

                                    cb();
                                }
                            );
                        }
                    });
                });
                async.waterfall(tasks, cb);
            },
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

};